<?php

/**
 * User base class
 *
 * @author    Mon Zafra <monzee at gmail>
 * @copyright (c)2009 Mon Zafra
 * @license   http://monzee.wordpress.com/license New BSD
 * @version   $Id: BaseAdmin_Doctrine_User.php 38 2009-02-18 17:12:39Z monzee $
 */
abstract class BaseAdmin_Doctrine_User extends Doctrine_Record
{
    public function setTableDefinition()
    {
        $this->setTableName('users');
        $this->hasColumn('id', 'integer', 5, array('type' => 'integer', 'autoincrement' => true, 'primary' => true, 'length' => '5'));
        $this->hasColumn('username', 'string', 32, array('type' => 'string', 'length' => '32'));
        $this->hasColumn('password', 'string', 64, array('type' => 'string', 'length' => '64'));
        $this->hasColumn('email', 'string', 256, array('type' => 'string', 'length' => '256'));
        $this->hasColumn('created_at', 'timestamp', 25, array('type' => 'timestamp', 'length' => '25'));
        $this->hasColumn('updated_at', 'timestamp', 25, array('type' => 'timestamp', 'length' => '25'));


        $this->index('username', array('fields' => array(0 => 'username')));
        $this->option('charset', 'utf8');
    }

    public function setUp()
    {
        $this->hasMany('Admin_Doctrine_Role as Roles', array('refClass' => 'Admin_Doctrine_UserRole',
                                                             'local' => 'user_id',
                                                             'foreign' => 'role_id'));
    }
}
